package com.zhiyou100.poly2;

public class BirdOpe {

    //给鸟治疗的操作
    //对鸟进行治疗
    public void treat(Bird bird) {
        if (bird instanceof Ostrich){
            System.out.println("对鸵鸟" + bird.name + "进行治疗");
        }
        if (bird instanceof  Pigeon){
            System.out.println("对鸽子" + bird.name + "进行治疗");
        }
    }
    //多态的使用常见地方：方法的形参是父类类型    还有就是方法的返回值是父类类型
    public Bird getBird(){
        return new Ostrich();
    }

    public static void main(String[] args) {
        BirdOpe ope = new BirdOpe();
        Bird bird = new Ostrich();
        bird.name = "大黑";
        ope.treat(bird);

        bird = new Pigeon();
        bird.name = "小白";
        ope.treat(bird);

    }


}

/**
 *
 *
 *
 */

